﻿using System;

namespace SteeringBehaviors
{
	// Token: 0x0200021B RID: 539
	public class Align : SteerBehavior
	{
		// Token: 0x06000B51 RID: 2897 RVA: 0x0005F2B1 File Offset: 0x0005D4B1
		public Align(MovementCharacter agent, IKinematic target) : base(agent, target)
		{
		}

		// Token: 0x06000B52 RID: 2898 RVA: 0x0005F2DC File Offset: 0x0005D4DC
		public override SteeringOutput GetSteering()
		{
			float num = this.targetOrientation - this.agent.orientation;
			num = base.MapToRange(num);
			float num2 = num;
			if (num < 0f)
			{
				num2 = -num;
			}
			if (num2 < this.targetRadius)
			{
				this.pSteering.angular = 0f;
				return this.pSteering;
			}
			float num3;
			if (num2 > this.slowRadius)
			{
				num3 = this.agent.MaxRotation;
			}
			else
			{
				num3 = this.agent.MaxRotation * num2 / this.slowRadius;
			}
			num3 *= num / num2;
			this.pSteering.angular = num3 - this.agent.rotation;
			this.pSteering.angular /= this.timeToTarget;
			float num4 = this.pSteering.angular;
			if (this.pSteering.angular < 0f)
			{
				num4 = -this.pSteering.angular;
			}
			float maxAngularAccel = this.agent.MaxAngularAccel;
			if (num4 > maxAngularAccel)
			{
				this.pSteering.angular /= num4;
				this.pSteering.angular *= maxAngularAccel;
			}
			return this.pSteering;
		}

		// Token: 0x04001066 RID: 4198
		public float targetRadius = 2f;

		// Token: 0x04001067 RID: 4199
		public float slowRadius = 5f;

		// Token: 0x04001068 RID: 4200
		public float timeToTarget = 0.1f;

		// Token: 0x04001069 RID: 4201
		public float targetOrientation;
	}
}
